package com.lancoo.znbkxx.teacher.aibkTestCoach.checkKnowledgePoint

import com.lancoo.znbkxx.teacher.aibkTestCoach.kBase.KBaseRecyclerViewHolder
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.lancoo.znbkxx.teacher.aibkTestCoach.kBase.KBaseRecyclerAdapter
import com.lancoo.znbkxx.teacher.R
import kotlinx.android.synthetic.main.aibk_adapter_item_knowledgepoint.view.*

class AibkKnowledgePointItem(
        val context: Context,
        val listName: ArrayList<String>
) : KBaseRecyclerAdapter() {

    override fun getHolderView(parent: ViewGroup?, position: Int): View {
        return LayoutInflater.from(context)
                .inflate(R.layout.aibk_adapter_item_knowledgepoint, parent, false)
    }

    override fun onBindViewHolder(holder: KBaseRecyclerViewHolder, position: Int) {
        holder.convertView.TvKnowledgePoint.text = listName[position]


        holder.convertView!!.LlKnowledgePoint.setOnClickListener {
            clickListener!!.onClick(position)
        }

    }

    override fun getItemCount(): Int {
        return listName.size
    }

    override fun getItemViewType(position: Int): Int {
        return position
    }

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }

    /*
    * 选项点击事件监听
    * */
    interface OnClickListener {
        fun onClick(position:Int)
    }

    private var clickListener: OnClickListener? = null

    fun setClickListener(clickChildListener: OnClickListener?) {
        this.clickListener = clickChildListener
    }

}